﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

[Serializable]
public class ShipStruct
{
    public enum ShipRank
    {
        RANK_FOLK,
        RANK_MILITARY,
        RANK_FORBIDDEN,
    }

    public float StructurePoint {
        set { 
            m_StructurePoint = Math.Min(value, StructurePointMax);
            //if (OnStructChangedCallback != null)
            //    OnStructChangedCallback(m_StructurePoint);
        }
        get { return m_StructurePoint; }
    }
    public float StructurePointMax {
        set { m_StructurePointMax = value; }
        get { return m_StructurePointMax * m_StructMultiply; }
    }
    public string Influence {
        set {
            m_Influence = value;
            if (OnInFluenceChanged != null)
                OnInFluenceChanged(m_Influence);
        }
        get { return m_Influence; }
    }
    public float DetectRange
    {
        set { m_DetectRange = value; }
        get { return m_DetectRange; }
    }

    public float Electric{
        set {
            m_Electric = Mathf.Clamp(value, 0, m_ElectricMax);
            //if (OnElectricChangedCallback != null)
            //    OnElectricChangedCallback(m_Electric);
        }
        get { return m_Electric; }
    }
    [NonSerialized]
    public GlobalDefine.OnStringCallback OnInFluenceChanged;
    //[NonSerialized]
    //public CallbackFloat OnStructChangedCallback;
    //[NonSerialized]
    //public CallbackFloat OnElectricChangedCallback;

    public bool LoadStruct = false;
    public float DigOreEta = 1;
    public float VelocityMax = 120f;
    public float RotateSpeedMax = 80;
    public float m_StructurePoint = 1;
    public float m_StructurePointMax = 1;
    public int m_Price=0;
    public string m_Influence="";
    public string m_ResearchInfluence = "";
    public float m_DetectRange=20;
    public float m_ElectricMax=800;
    private float m_Electric= 800;
    public float m_ElectricIncrement=12;
    public float m_ElectricPower = 60;
    public string m_Name = "none";
    public string Description = "none";
    public Driver.DriveLevel m_LicenseLevel;
    public ShipRank m_Rank = ShipRank.RANK_MILITARY;
    public List<WeaponSlotStruct> m_Weapons = new List<WeaponSlotStruct>();
    public List<FeatureSlotStruct> m_Features = new List<FeatureSlotStruct>();


    public float m_StructMultiply = 1;

}

public class WeaponSlotStruct
{
    public string m_TypeS;
    public bool m_IsAutoFire=false;
    public bool m_Firing = false;
    public int m_GroupIndex=1;
    public float m_Angle = 0;
    public float m_CoolingTime = 0;
    public float m_ErrorValue = 0;
    public bool m_HasFireLicense = true;

}
public class FeatureSlotStruct
{
    public string m_TypeS;
    public float m_Value = 0;
    public bool m_Switch = false;
}